package com.macrosolution.exdebito.filters

import com.macrosolution.exdebito.User;

/**
 * LogFilters
 * A filters class is used to execute code before and after a controller action is executed and also after a view is rendered
 */
class LogFilters {

	def springSecurityService
    def filters = {
        all(controller:'*', action:'*') {
            before = {
				Thread.currentThread().sleep(800);
					
					
				
            }
            after = { Map model ->
				
					User secUser=null
					try{
					secUser =springSecurityService.currentUser
					}catch(Exception ex){}
					println 'CALLED : CONTROLLER['+controllerName+'] ACTION['+actionName+'] PARAMS['+params+'] '+((secUser)?'USER ['+secUser.username+']':'')
				
				
            }
            afterView = { Exception e ->

            }
        }
    }
}
